package com.cn.整合.Spring;

import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * @author: dlr
 * @data: 2019/8/20 23:39
 * @desc: 消费者监听消息(配置在消费者)
 */
@Component
public class projectMsgLinster implements MessageListener {
    @Override
    public void onMessage(Message message) {
        TextMessage textMessage = (TextMessage)message;
        try {
            //获取消息信息内容
            String text = textMessage.getText();
            //打印信息
            System.out.println("监听器监听"+text);
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}
